package com.poul.acfun.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.poul.acfun.R;
import com.poul.acfun.ac_view.fragment.ChanelFragment;
import com.poul.acfun.ac_view.fragment.FanJuFragment;
import com.poul.acfun.ac_view.fragment.HappyFragment;
import com.poul.acfun.ac_view.fragment.NoticeFragment;
import com.poul.acfun.ac_view.fragment.PushFragment;
import com.poul.acfun.ac_view.fragment.WenZhangFragment;

/**
 * Created by poul on 2016/10/20.
 */

public class MainViewPagerAdapter extends FragmentPagerAdapter {
    private String[] titles;

    public MainViewPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        titles = context.getResources().getStringArray(R.array.tab_title);
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new NoticeFragment();
                break;
            case 1:
                fragment = new PushFragment();
                break;
            case 2:
                fragment = new FanJuFragment();
                break;
            case 3:
                fragment = new HappyFragment();
                break;
            case 4:
                fragment = new WenZhangFragment();
                break;
            case 5:
                fragment = new ChanelFragment();
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
